package com.jiuhaohealth.kangxun360.main.po;

import com.jiuhaohealth.base.superpage.BeanSuper;
import com.jiuhaohealth.common.table.TableChooser;

public class Question implements BeanSuper {
    private String qid;

    private String qname;

    private String qtype;

    private Integer priority;

    private String aid;

    protected String table = "question";

    protected String tableOffset = "";

    public String getQid() {
        return qid;
    }

    public void setQid(String qid) {
        this.qid = qid == null ? null : qid.trim();
    }

    public String getQname() {
        return qname;
    }

    public void setQname(String qname) {
        this.qname = qname == null ? null : qname.trim();
    }

    public String getQtype() {
        return qtype;
    }

    public void setQtype(String qtype) {
        this.qtype = qtype == null ? null : qtype.trim();
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public String getAid() {
        return aid;
    }

    public void setAid(String aid) {
        this.aid = aid == null ? null : aid.trim();
    }

    /** 
     * 拷贝，将对象中的字段全部拷贝到子对象中
     * @param bean 接收对象的子类
     * @return 拷贝完成后的子类
     */ 
    public  <T extends Question> T copy(T bean) {
        bean.setQid(getQid());
        bean.setQname(getQname());
        bean.setQtype(getQtype());
        bean.setPriority(getPriority());
        bean.setAid(getAid());
        return bean;
    }

    /** 
     * 格式化显示
     */ 
    @Override
    public String toString() {
        return "{" + 
        	", qid:" + getQid() + 
        	", qname:" + getQname() + 
        	", qtype:" + getQtype() + 
        	", priority:" + getPriority() + 
        	", aid:" + getAid() + 
        "}";
    }

    /**
     * 设置表名
     * @param table 设置表名
     */
    public void setTable(String table) {
        this.table=table;
    }

    public String getTable() {
        return table;
    }

    /**
     * 设置分表的下标
     * @param tableOffset 设置分表的下标
     */
    public void setTableOffset(String tableOffset) {
        this.tableOffset=tableOffset;
        if(!tableOffset.equals(""))
        	this.table+=tableOffset;
    }

    public String getTableOffset() {
        return tableOffset;
    }

    /**
     * 根据分表选择器选择分表下标
     * @param DataSourceChooser chooser 
     */
    public void setTableOffset(TableChooser chooser) {
        String offset=chooser.choose();
        this.tableOffset=offset;
        if(!offset.equals(""))
        	this.table+=offset;
    }
}